<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06_盒子模型外间距测试</title>
    <style>
        *{
            margin: 0;
            padding:0;
        }
        .fu{
            background-color: rgba(255,0,0,0.5);
            /*父子粘连:子元素的上外边距会导致父元素一起下移*/
            /*给父元素设置BFC结界保护*/
            overflow: hidden;
        }
        .fu>div{
            width: 100px;
            height: 100px;
            background-color: rgba(0,255,0,0.5);
            border: 2px solid #00F;
            color: #fff;
            font-size: 25px;
            font-weight:  bold;
        }
        .z1 {
            margin-bottom: 50px;
            margin-top: 50px;
        }
        .z2 {
            margin-top: 70px;
        }
        .z3 {
            margin: 10px;       /*上右下左*/
            margin: 10px 20px;
            margin: 10px 20px 30px;
            margin: 10px 20px 30px 40px;
            /*实现块级元素自身的水平居中 auto会自动将元素的左右外间距计算成相等的值*/
            margin: 0 auto;
        }
        .z4 {
            margin-bottom: 100px;
        }
        span {
            background-color: rgba(0,0,255,0.5);
            border: 2px solid #00F;
        }
        .s2 {
            margin: 20px;
            padding: 40px;
        }
    </style>
</head>
<body>
<span>span</span><span class="s2">span</span><span>span</span>
<!--.fu>.z*4-->
<div class="fu">
    <div class="z1">111</div>
    <div class="z2">222</div>
    <div class="z3">333</div>
    <div class="z4">444</div>
</div>
</body>
</html>